/* GUI CONVERTED from reoptr7b.p (converter v1.75) Sat Aug 12 23:07:44 2000 */
/* reoptr7b.p - SETUP OPERATION TRANSACTION BY PART (Sub Procedure)     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 8.5      LAST MODIFIED: 05/30/96              BY: lal *J0PN*/


/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb              */
         {mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reoptr7b_p_1 "Start Time"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoptr7b_p_2 "Routing"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoptr7b_p_3 "Elapsed or Stop Time"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoptr7b_p_4 "BOM"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

         define shared variable wr_recno as recid.
         define shared variable wc_recno as recid.
         define shared variable op_recno as recid.
         define shared variable wo_recno as recid.
         define shared variable ophist_recid as recid.
         define shared variable pay_rate like emp_pay_rate.
         define shared variable site like rps_site no-undo.
         define shared variable prline like rps_line no-undo.
         define shared variable part like op_part no-undo.
         define shared variable op like ps_op no-undo.
         define shared variable gldetail like mfc_logical no-undo.
         define shared variable gldtrans like mfc_logical no-undo.
         define shared variable shift like op_shift.
         define shared variable earn like op_earn.
         define shared variable last_date like op_date.
         define shared variable routing as character format "x(18)"
            label {&reoptr7b_p_2}.
         define shared variable bom_code as character format "x(18)"
            label {&reoptr7b_p_4}.
         define shared variable opemp like op_emp.

         define variable trnbr like op_trnbr format ">>>>>>>9".
         define variable wr_recid as recid.
         define buffer ophist for op_hist.
         define variable start_setup as character format "99:99:XX"
            label {&reoptr7b_p_1}.
         define variable start_run like start_setup.
         define variable stop_setup like start_setup
            label {&reoptr7b_p_3}.
         define variable stop_run like stop_setup.
         define variable locked-file as character.
         define variable msg-counter as integer no-undo.

         define shared frame b.

         FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
part           colon 22 pt_desc1       no-label
            op             colon 22 ro_desc        no-label
            prline         colon 22 ln_desc        no-label
            routing        colon 22 bom_code
            op_wkctr       colon 22 op_mch wc_desc no-label no-attr-space
            op_dept        colon 22 dpt_desc no-label no-attr-space
                                                         start_run      colon 65
            op_act_setup   colon 22                       stop_run      colon 65
            op_earn        colon 22 ea_desc no-label no-attr-space
            op_trnbr       colon 22 format ">>>>>>>9"
            op_wo_lot      colon 41
          SKIP(.4)  /*GUI*/
with frame b side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


         /* SET EXTERNAL LABELS */
         setFrameLabels(frame b:handle).

          /* Re-find Work Order, Routing and Employee records */
          find wo_mstr where recid(wo_mstr)   = wo_recno no-lock.
          find wr_route where recid(wr_route) = wr_recno no-lock.
          find emp_mstr where emp_addr        = opemp    no-lock no-error.

          do
          transaction
          with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.


             create op_hist.

             {mfnoptr.i}

             assign op_emp = opemp
                op_wo_nbr = wr_nbr
             op_tran_date = today
                 op_shift = shift
                 op_wo_op = op
                op_wo_lot = wr_lot
                  op_type = "LABOR"
                 op_wkctr = wr_wkctr
                   op_mch = wr_mch
                  op_date = last_date
                  op_part = part
              op_site = site
              op_line = prline
         op_milestone = wr_milestone
                  op_earn = earn.
           op_std_run = wr_run.

             ophist_recid = recid(op_hist).
             op_recno = recid(op_hist).

             start_run = "000000".
             stop_run = "000000".

             display op_wkctr op_mch op_act_setup op_earn
                 start_run stop_run op_trnbr format ">>>>>>>9" op_wo_lot.

             find wc_mstr no-lock where wc_wkctr = op_wkctr
             and wc_mch = op_mch no-error.
             if available wc_mstr
             then display wc_desc wc_dept @ op_dept.
             else display " " @ wc_desc " " @ op_dept.

         /* Added section */
             if not wr_milestone then do:
                find first wr_route no-lock where wr_lot = wo_lot
                and wr_op > op no-error.
                if available wr_route then do:
                   {mfmsg.i 560 2}
                end.
                find wr_route no-lock where recid(wr_route) = wr_recno.
             end.

             {gprun.i ""reoptr7a.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


             if keyfunction(lastkey) = "end-error" then undo, leave.
         /* End of added section */

         /* Added section */
             msg-counter = 0.
             repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

                release wo_mstr.
                release wr_route.
            find wo_mstr exclusive-lock where recid(wo_mstr) = wo_recno
                   no-wait no-error.
                if available wo_mstr then do:
               find wr_route exclusive-lock
               where recid(wr_route) = wr_recno
                      no-wait no-error.
                end.
                if locked wo_mstr
                or locked wr_route
                then do:
                   if locked wo_mstr then locked-file = "wo_mstr".
                   else
                  if locked wr_route then locked-file = "wr_route".
                   if msg-counter modulo 100 = 0 then do:
                      {mfmsg03.i 1400 1 locked-file
                        kblabel(""end-error"") """"
                        "fill(""."",(msg-counter / 100) mod 20)" }
                      readkey pause 1.
                      if keyfunction(lastkey) = "end-error" then leave.
                      apply lastkey.
                   end.
                   msg-counter = msg-counter + 1.
                   next.
                end.
                if available wo_mstr and available wr_route then leave.
             end.
/*GUI*/ if global-beam-me-up then undo, leave.

             hide message.

             if keyfunction(lastkey) = "end-error" then undo, leave.
         /* End of added section */

             pay_rate = wc_lbr_rate.    /* the default if no
                                           employee rate gets used */
             if emp_pay_type = "HR" and emp_pay_rate <> 0 then do:
                pay_rate = emp_pay_rate.
                if earn <> "" and available ea_mstr
                   then pay_rate = pay_rate * ea_rate.
             end.

             wr_act_setup = wr_act_setup + op_act_setup.
             wr_act_run = wr_act_run + op_act_run.

             wr_recno = recid(wr_route).
             wc_recno = recid(wc_mstr).
             op_recno = recid(op_hist).

             {gprun.i ""reoptrc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


             if (index("QH",wr_status) > 0 or wr_status = "" )
             and op_act_setup > 0
             then wr_status = "S".
          end.
/*GUI*/ if global-beam-me-up then undo, leave.

